<?php
$countAberto = 0;
foreach ($this->data as $entity) {
    if ($entity->getSqTurma()->getSqSituacaoTurma()->getNoSituacaoTurma() == 'Aberto') {
        $countAberto++;
    }
}

if ($countAberto < 2) {
    ?>
    <!-- Icones -->
    <div class="row-fluid">
        <div class="span2 action-btn round-all">
            <a href="<?php echo $this->url('sisesporte-admin', array('controller' => 'pre-matricula', 'action' => 'new')) ?>" title="Cadastrar">
                <div><i class="icon-pencil"></i></div>
                <div><strong>Efetuar Pré-Matrícula</strong></div>
            </a>
        </div>
    </div>
    <?php
}
?>
<!-- Icones -->
<!-- Table -->
<div class="row-fluid">      
    <div class="span12">
        <!-- Portlet: Browser Usage Graph -->
        <div class="box" id="box-0">
            <h4 class="box-header round-top">Modalidades Pré-Matriculadas
                <a class="box-btn" title="close"><i class="icon-remove"></i></a>
                <a class="box-btn" title="toggle"><i class="icon-minus"></i></a>     
                <a class="box-btn" title="config" data-toggle="modal" href="#box-config-modal"><i class="icon-cog"></i></a>
            </h4>         
            <div class="box-container-toggle">
                <div class="box-content">
                    <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered bootstrap-datatable" id="datatable">
                        <thead>
                            <tr>
                                <th>Código Turma</th>
                                <th>Modalidade</th>
                                <th>Professor</th>
                                <th>Horário</th>
                                <th>Faixa Etária</th>
                                <th>Nº Vagas</th>
                                <th>Nível</th>
                                <th>Situacao</th>
                                <th>Teste</th>
                                <th>Período</th>
                                <th>Ações</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            foreach ($this->data as $entity):
                                ?>
                                <tr>
                                    <td class="center"><?php echo $entity->getSqTurma()->getCoTurma() ?></td>
                                    <td class="center"><?php echo $entity->getSqTurma()->getSqModalidadeProfessor()->getSqModalidade()->getNoModalidade(); ?></td>
                                    <td class="center"><?php echo $entity->getSqTurma()->getSqModalidadeProfessor()->getSqPessoa()->getSqPessoa()->getNoPessoa(); ?></td>
                                    <td class="center"><?php echo $entity->getSqTurma()->getSqHorarioInicio()->getNoHorario() . " às " . $entity->getSqTurma()->getSqHorarioTermino()->getNoHorario() ?></td>
                                    <td class="center"><?php echo $entity->getSqTurma()->getSqTipoFaixaEtaria()->getNoTipoFaixaEtaria(); ?></td>
                                    <td class="center"><?php echo $entity->getSqTurma()->getNuVaga(); ?></td>
                                    <td class="center"><?php echo $entity->getSqTurma()->getSqNivel()->getNoNivel(); ?></td>
                                    <td class="center"><?php echo $entity->getSqTurma()->getSqSituacaoTurma()->getNoSituacaoTurma(); ?></td>
                                    <td class="center">
                                        <span class="badge <?php echo ($entity->getSqTurma()->getInPreTeste() == 1) ? "badge-success" : "" ?>">
                                            <?php echo ($entity->getSqTurma()->getInPreTeste() == 1) ? "Sim" : "Não"; ?>
                                        </span>
                                    </td>
                                    <td class="center"><?php echo $entity->getSqTurma()->getInSemestre() . "º/" . $entity->getSqTurma()->getNuAno(); ?></td>
                                   
                                    <td class="center">
                                        <a class="btn btn-primary" href="<?php echo $this->url('sisesporte-admin-interna', array('controller' => 'pre-matricula', 'action' => 'view', 'id' => $entity->getSqPreMatricula()));
                                            ?>">
                                            <i class="icon-plus icon-white"></i>
                                            Ver Mais
                                        </a>
                                    </td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>